<div style="height:600px; position: relative ">

    <div class="mb20">

        <a role="button" ng-click="exportExcel()" class="btn btn-primary" >导出EXCEL</a>
        <div class="dib">
            <input type="text" ng-model="search.name" class="form-control dib mdw" >
            <a role="button" ng-click="searchName(search.name)"  class="btn btn-primary">搜索</a>
        </div>

        <div class="dib">
            <select class="form-control" ng-model="search.state" ng-change="setState(search.state)" >
                <option ng-repeat="state in states track by $index" value="{{$index}}">{{state}}</option>
            </select>
        </div>

    </div>

    <table class="table table-striped table-condensed table-bordered table-hover">
        <thead>
        <tr style="background-color: #0081c2; color: #FFFFFF">
            <td><input type="checkbox" ng-model="allChecked" ng-change="checkAll(allChecked)" ></td>
            <td>所有商品</td>
            <td ng-repeat="attr in showAttrs" ng-bind="attr.zhCn"></td>
            <td>购买时间</td>
            <td>待付金额</td>
            <td>已付金额</td>
            <td>优惠金额</td>
            <td>付款时间</td>
            <td>状态</td>
            <td>支付方式</td>
            <td>最新备注</td>
            <td>操作</td>
        </tr>
        </thead>
        <tbody>
        <tr ng-repeat="model in models">
            <td><input type="checkbox" ng-model="model.checked" ></td>
            <td><p ng-repeat="p in model.production" ng-bind="p.name"></p></td>
            <td ng-repeat="attr in showAttrs" ng-bind="model[attr.en]" >
            </td>
            <td>{{model.createdAt | date:'yyyy-MM-dd '}}</td>
            <td>{{model.buyCost - model.paidAmount}}</td>
            <td>{{model.paidAmount}}</td>
            <td>{{model.cost - model.buyCost}}</td>
            <td>{{model.payTime | date:'yyyy-MM-dd '}}</td>
            <td>{{states[model.state]}}</td>
            <td>{{payMethods[model.payMethod]}}
            </td>
            <td>{{model.remarks[model.remarks.length-1].text}}
                <a class=" btn btn-primary btn-xs" ng-click="editObject(model)" data-toggle="modal" data-target="#remarkModal"><span
                        class="glyphicon glyphicon-pencil"></span></a>
            </td>
            <td><a class="btn btn-default"  role="button" href="#/order-detail/{{model.objectId}}">详情</a>
                <a class="btn btn-danger"   role="button" data-toggle="modal" data-target="#deleteModal"ng-click="showRemove(model)" role="button" >删除</a>
            </td>
        </tr>
        </tbody>
    </table>


    <h4  ng-if="models.length==0">暂无数据</h4>



    <div style="position: absolute; bottom: 0px" paging
         page= search.pageNo
         page-size= search.pageSize
         total= total
         paging-action = "paging(page)">
    </div>
</div>


<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button"
                        class="close"
                        data-dismiss="modal"
                        aria-hidden="true">x</button>
                <h3 id="userMgrLabel">删除</h3>
            </div>
            <div class="modal-body">
                <h4>是否删除{{deleteName}}</h4>
            </div>
            <div class="modal-footer">
                <button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
                <button class="btn btn-primary"
                        data-dismiss="modal"
                        aria-hidden="true"
                        ng-click="remove(deleteObject)"
                >确定</button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="remarkModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button"
                        class="close"
                        data-dismiss="modal"
                        aria-hidden="true">x</button>
                <h3 id="userMgrLabel">备注</h3>
            </div>
            <div class="modal-body">

                <div ng-if="editOrder.remarks.length>0">
                    <h4>历史备注</h4>
                    <table class="table table-striped table-condensed table-bordered table-hover">
                        <thead>
                        <tr style="background-color: #0081c2; color: #FFFFFF">
                            <td>备注</td>
                            <td>操作人</td>
                            <td>时间</td>
                        </tr>
                        </thead>
                        <tbody>
                        <tr ng-repeat="r in editOrder.remarks">
                            <td>{{r.text}}</td>
                            <td>{{r.handler}}</td>
                            <td>{{r.createdAt | date:'yyyy-MM-dd '}}</td>
                        </tr>
                        </tbody>
                    </table>

                </div>

                <h4>新增备注</h4>
                <form name="userForm" class="form-horizontal" role="form">
                    <div class="form-group" >
                        <label class="col-sm-2 control-label">备注</label>
                        <div class="col-sm-10">
                            <textarea row="3" type="text" class="form-control"   ng-model="newRemark.text">
                            </textarea>
                        </div>
                    </div>


                    <div class="checkbox">
                        <div class="col-sm-2"> </div>
                        <label>
                            <input ng-model = "newRemark.visual" type="checkbox"> 客户端可见
                        </label>
                    </div>

                </form>

            </div>
            <div class="modal-footer">
                <button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
                <button class="btn btn-primary"
                        data-dismiss="modal"
                        aria-hidden="true"
                        ng-click="saveRemark(newRemark, editOrder)"
                >确定</button>
            </div>
        </div>
    </div>
</div>



